﻿@model Company
@Html.Extra()
@{
    Layout = "~/Views/Shared/OA/_Edit.cshtml";
}
@section Toolbar
{
    @*@Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })*@
    @Html.MyNet().Button(new ButtonOptions { Text = "保存", Click = "save" })
}
@section Main
{
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.Key)

    <table>
        <tr>
            <th>
                <b>*</b> @Html.LabelFor(model => model.Name, "公司名称：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.Name, new ValidateOptions
                {
                    RequiredError = "公司名称",
                    LengthMax = 64
                })
            </td>
        </tr>

        <tr>
            <th>
                @Html.LabelFor(model => model.Logo, "Logo图片：")
            </th>
            <td>
                @Html.MyNet().UploadFor(model => model.Logo, new UploadOptions
                {
                    AttachmentKey = Model.Key,
                    AttachmentTypeKey = "CompanyLogo",
                    UploadMode = UploadMode.ImageSingle,
                    ImageWidth = 320,
                    ImageHeight = 160,
                    PreviewImageWidth = 320,
                    PreviewImageHeight = 160,
                })

            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.VisitingCard, "名片：")
            </th>
            <td>
                @Html.MyNet().UploadFor(model => model.VisitingCard, new UploadOptions
                {
                    AttachmentKey = Model.Key,
                    AttachmentTypeKey = "CompanyVisitingCard",
                    UploadMode = UploadMode.ImageSingle,
                    ImageWidth = 280,
                    ImageHeight = 500,
                    PreviewImageWidth = 280,
                    PreviewImageHeight = 500,
                })

            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.QRCode, "二维码图片：")
            </th>
            <td>
                @Html.MyNet().UploadFor(model => model.QRCode, new UploadOptions
                {
                    AttachmentKey = Model.Key,
                    AttachmentTypeKey = "CompanyQRCode",
                    UploadMode = UploadMode.ImageSingle,
                    ImageWidth = 150,
                    ImageHeight = 150,
                    PreviewImageWidth = 150,
                    PreviewImageHeight = 150,
                })

            </td>
        </tr>
        <tr>
            <th>
                <b>*</b>@Html.LabelFor(model => model.MobilePhone, "手机：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.MobilePhone, new ValidateOptions
                {
                    RequiredError = "手机",
                    LengthMax = 64
                })
            </td>
        </tr>

        <tr>
            <th>
                @Html.LabelFor(model => model.QQ, "QQ：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.QQ)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Bus, "公交路线：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.Bus)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Metro, "地铁路线：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.Metro)
            </td>
        </tr>
        <tr>
            <th>
                <b>*</b>  @Html.LabelFor(model => model.Province, "所属地区")
            </th>
            <td>
                @Html.MyNet().DropDownListFor(model => model.Province, Url.Action("ReadForParent", "Area", new { Area = "Common" }), "Key", "Name", "请选择省", new ValidateOptions
                {
                    RequiredError = "请选择省",
                }, new { style = "width:120px;" })
                @Html.MyNet().DropDownListFor(model => model.City, Url.Action("ReadForParent", "Area", new { Area = "Common" }), "Province", "ParentKey", "Key", "Name", "请选择市", new ValidateOptions
                {
                    RequiredError = "请选择市",
                }, new { style = "width:120px;" })
                @Html.MyNet().DropDownListFor(model => model.District, Url.Action("ReadForParent", "Area", new { Area = "Common" }), "City", "ParentKey", "Key", "Name", "请选择区", null, new { style = "width:120px;" })
                @Html.MyNet().ValidationMessageFor(model => model.Province)
                @Html.MyNet().ValidationMessageFor(model => model.City)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Address, "地址：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.Address)
            </td>
        </tr>
        <tr>
            <th>
                @Html.Label("请标注位置")
            </th>
            <td>
                @*<button type="button" onclick="searchBy('#Address');">地图上搜索</button>*@
                @Html.MyNet().TextBoxFor(model => model.Longitude, null, new { style = "width:100px;", placeholder = "lon" })
                @Html.MyNet().TextBoxFor(model => model.Latitude, null, new { style = "width:100px;", placeholder = "lat" })
                @Html.MyNet().TextBoxFor(model => model.Zoom, null, new { style = "width:100px;", placeholder = "zoom" })
            </td>
        </tr>
        <tr>
            <th></th>
            <td>
                <div id="allmap"></div>
            </td>
        </tr>

        <tr>
            <th>
                @Html.LabelFor(model => model.Copyright, "版本：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.Copyright)
            </td>
        </tr>

        <tr>
            <th>
                @Html.LabelFor(model => model.Record, "备案：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.Record)
            </td>
        </tr>

        <tr>
            <th>
                @Html.LabelFor(model => model.StatisticalCode, "统计代码：")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.StatisticalCode)
            </td>
        </tr>

        <tr>
            <th>
                @Html.LabelFor(model => model.Keyword, "默认关键字：")
            </th>
            <td>
                @Html.MyNet().TextAreaFor(model => model.Keyword, new ValidateOptions
                {
                    LengthError = "不能超过256字符",
                    LengthMax = 256
                })
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Summary, "默认描述：")
            </th>
            <td>
                @Html.MyNet().TextAreaFor(model => model.Summary, new ValidateOptions
                {
                    LengthError = "不能超过256字符",
                    LengthMax = 256
                })
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Describe, "简介")
            </th>
            <td>
                @Html.MyNet().EditorFor(model => model.Describe, new EditorOptions
                {
                    AttachmentKey = Model.Key,
                    EditorConfig = EditorConfig.Rich,
                })
            </td>
        </tr>
    </table>
}
<script>

    function save() {
        var form = $("form");
        sync(form);
        if (!form.valid()) return;
        $.ajax
            ({
                url: '/cms/company/createOrModify',
                data: form.serialize(),
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    alert('保存成功！');
                }
            });
    }

</script>
